package com.example.netdemo.viewmodel

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.example.netdemo.RequestParams
import com.example.netdemo.base.BaseViewModel
import com.example.netdemo.model.LoginModel
import com.example.netdemo.repository.LoginRepository
import com.example.netdemo.retrofit.Resource


class LoginViewModel : BaseViewModel() {

    private val loginRepository by lazy { LoginRepository.instance }

    fun login(account: String, pws: String,  markEnum: String) : LiveData<Resource<LoginModel>> {
        return launchAndLoad(true) {
            val (liveData, disposable) = loginRepository.login(RequestParams.loginParams(account, pws, markEnum))
            addDisposable(disposable)
            liveData
        }
    }
}